package org.wltea.analyzer.extend;

import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

import org.wltea.analyzer.cfg.Configuration;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

public class Test {

	public static void main(String[] args) {
		System.out.println(getIKWordTerms("别墅图纸", true));
	}

	// 获得分词结果
	public static List<String> getIKWordTerms(String word, boolean useSmart) {
		List<String> list = new ArrayList<String>();
		try {
			StringReader sr = new StringReader(word);
			Configuration cfg = EmptyConfig.getInstance();
			cfg.setUseSmart(useSmart);
			IKSegmenter ik = new IKSegmenter(sr, cfg);

			Lexeme lexeme = null;
			while ((lexeme = ik.next()) != null) {
				String term = lexeme.getLexemeText();
				list.add(term);

			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
}
